{extend name="base"/}
{block name="main"}
<div class="Hui-article">
    <article class="cl pd-20">
 <div id="tab_demo" class="HuiTab" style="margin-bottom: 15px; position:relative;">
                        <div class="tabBar clearfix">
                            <span onclick="window.location.href='__CONF_SITE__admin/article/article_list'">文章列表</span>
                            <span class="current">文章分类</span>
<div onclick="article_class_add('添加类型','__CONF_SITE__admin/article/add_article_class','1000px','800px')"  class="n_tab_add"><i class="Hui-iconfont">&#xe600;</i>添加类型</div>
                        </div>
                    </div>
        <div>

            <div class="mt-20">
                <table class="table table-border table-bordered table-bg table-hover table-sort">
                    <thead>
                    <tr class="text-c">
                        <th style="width: 122px;"><i class="Hui-iconfont">&#xe6f5;</i></th>
                        <th>分类名称</th>
                        <th>分类图标</th>
                        <th>创建时间</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    {foreach name="class_list" item="v1"}
                    <tr class="pid_0" style="height: 30px;">
                        <td>
                            {if condition="$v1['child_list'] neq array()"}
                            <a href="javascript:;" onclick="tab_switch({$v1['class_id']})" class="tab_jia_{$v1['class_id']}" style="display: block;"><i class="Hui-iconfont" style="padding-left: 45px;">&#xe600;</i></a>
                            <a href="javascript:;" onclick="tab_switch({$v1['class_id']})" class="tab_jian_{$v1['class_id']}" style="display: none;"><i class="Hui-iconfont" style="padding-left: 45px;">&#xe6a1;</i></a>
                            {/if}
                        </td>
                        <td style="text-align: center;">{$v1['name']}</td>
                        <td style="text-align: center;"><img src="{$v1['class_img']}" onerror="this.src='/public/goods/img/default_goods_image_240.gif'" width="50px;"></td>
                        <td style="text-align: center;"> {$v1.create_time}  </td>
                        <td style="text-align: center;">
                            <a style="text-decoration:none;color:#0066cc;" title="编辑" onclick="goods_cate_edit('类型编辑','__CONF_SITE__admin/Article/edit_article_class&class_id={$v1.class_id}','1000','800')" href="javascript:;">
                                编辑
                            </a>
                            <a style="text-decoration:none;color:#0066cc;" title="删除" href="javascript:void(0);" onclick="class_del({$v1['class_id']})">
                                删除
                            </a>
                        </td>
                    </tr>
                    {foreach name="v1['child_list']" item="v2"}
                    <tr class="pid_{$v1['class_id']}" style="height: 30px;display: none;">
                        <td>
                            <!--{if condition="$v2['child_list'] neq array()"}-->
                            <!--<a href="javascript:;" onclick="tab_switch({$v2['class_id']})" class="tab_jian_{$v2['class_id']}" style="display: block;"><i class="Hui-iconfont">&#xe6a1;</i></a>-->
                            <!--<a href="javascript:;" onclick="tab_switch({$v2['class_id']})" class="tab_jia_{$v2['class_id']}" style="display: none;"><i class="Hui-iconfont">&#xe600;</i></a>-->
                            <!--{/if}-->
                        </td>
                        <td style="text-align: center;"><span style="color:#ccc;">|——</span>{$v2['name']}</td>
                        <td style="text-align: center;"><img src="{$v2['class_img']}" width="50px;"></td>
                        <td style="text-align: center;"> {$v2.create_time}  </td>
                        <td style="text-align: center;">
                            <a style="text-decoration:none;color:#0066cc;" title="编辑" onclick="goods_cate_edit('类型编辑','__CONF_SITE__admin/Article/edit_article_class&class_id={$v2.class_id}','1000','800')" href="javascript:;">
                                编辑
                            </a>
                            <a style="text-decoration:none;color:#0066cc;" title="删除" href="javascript:void(0);" onclick="class_del({$v2['class_id']})">
                                删除
                            </a>
                        </td>
                    </tr>
                    <!--{foreach name="v2['child_list']" item="v3"}-->
                    <!--<tr class="pid_{$v2['class_id']} pid_{$v1['class_id']}" style="height: 30px;display:none;">-->
                        <!--<td></td>-->
                        <!--<td style="text-align: center;"><span style="color:#ccc;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|——</span>{$v3['name']}</td>-->
                        <!--<td style="text-align: center;"><img src="{$v3['class_img']}" width="50px;"></td>-->
                        <!--<td style="text-align: center;"> {$v3.create_time} </td>-->
                        <!--<td style="text-align: center;">-->
                            <!--<a style="text-decoration:none;color:#0066cc;" title="编辑" onclick="goods_cate_edit('类型编辑','__CONF_SITE__admin/Article/edit_article_class&class_id={$v3.class_id}','800','500')" href="javascript:;">-->
                                <!--编辑-->
                            <!--</a>-->
                            <!--<a style="text-decoration:none;color:#0066cc;" title="删除" href="javascript:void(0);" onclick="class_del({$v3['class_id']})">-->
                                <!--删除-->
                            <!--</a>-->
                        <!--</td>-->
                    <!--</tr>-->
                    <!--{/foreach}-->
                    {/foreach}
                    {/foreach}
                    </tbody>
                </table>
                <div class="n_page_no">
                </div>
            </div>
        </div>
        {/block}
        {block name="script"}
        <script type="text/javascript">
            function tab_switch(module_id){
                if($(".pid_"+module_id).css('display') != 'none'){
                    $(".tab_jian_"+module_id).hide();
                    $(".tab_jia_"+module_id).show();
                    $(".pid_"+module_id).hide(300);
                }else{
                    $(".tab_jian_"+module_id).show();
                    $(".tab_jia_"+module_id).hide();
                    $(".pid_"+module_id).show(500);
                }
            }
            /*分类-添加*/
            function article_class_add(title,url,w,h){
                layer.open({
                    type: 2,
                    area: [w, h],
                    fix: false, //不固定
                    maxmin: true,
                    shade:0.4,
                    title: title,
                    content: url,
                    scrollbar:false
                });
            }
            /*分类-编辑*/
            /*分类-编辑*/
            function goods_cate_edit(title,url,w,h){
                layer_show(title,url,w,h);
            }
            /*分类-删除*/
            function class_del(id){
                layer.confirm('确认要删除吗？',function(index){
                    //此处请求后台程序
                    //后台处理
                    $.ajax({
                        type : "post",
                        url : "{:url('admin/article/del_article_class')}",
                        data : {
                            "class_id" : id,
                        },
                        success : function(data) {
                            if(data['code'] > 0){
                                layer.msg('删除成功', {icon: 1, time: 1000},function () {
                                    window.location.reload();
                                });
                            }else {
                                layer.msg('删除失败', {icon: 2, time: 1000});
                            }
                        }
                    })
                });
            }
        </script>
        {/block}